#pragma once;
/**
 * The Technique class encompasses the functionality of a technique 
 * that is described in the cgFX effect file.
 */

#include "Object.h"

class Pass;

class Technique : public Object
{
public:
    typedef std::vector<Pass*> PassList;

    // An invalid technique that is used when 
    // a user asks the effect for a technique that doesn't exist.
    static Technique InvalidTechnique;

    // Returns true if this is a valid technique for the current platform
    bool IsValid() const;

    const std::string& GetTechniqueName() const;

    PassList& GetPasses();
    Pass& GetPassByName( const std::string& passName );

    // Causes the technique to the be current technique
    // To be used for rendering.
    // Returns true if the technique was successfully bound.
    bool BeginTechnique();

    // Ends the technique by unbinding the technique.
    void EndTechnique();
protected:
    // Delete the technique, removing all passes.
    void Destroy();

private:
    typedef std::map< std::string, Pass* > PassMap;

    friend class Effect;
    friend class EffectManager;

    // Techniques cannot be created directly. They will be owned by the 
    // Effect class that defines them.
    Technique( CGcontext context, CGtechnique technique );
    virtual ~Technique();

    CGtechnique m_cgTechnique;
    CGcontext   m_cgContext;

    PassList    m_Passes;
    PassMap     m_PassesByName;

    // The name of the technique
    // If the technique is not valid, it will have an empty name.
    std::string m_TechniquName;
    bool        m_bIsValid;
};
 